package cn.lcvc.xnc.application.web.action.backstage.waste;

import cn.lcvc.xnc.application.common.model.result.ResponseData;
import cn.lcvc.xnc.application.dao.WasteDisposalSiteVirescencePictureMapper;
import cn.lcvc.xnc.application.model.WasteDisposalSiteVirescence;
import cn.lcvc.xnc.application.model.WasteDisposalSiteVirescencePicture;
import cn.lcvc.xnc.application.model.query.WasteDisposalSiteVirescencePictureQuery;
import cn.lcvc.xnc.application.model.query.WasteDisposalSiteVirescenceQuery;
import cn.lcvc.xnc.application.service.WasteDisposalSiteVirescencePictureService;
import cn.lcvc.xnc.application.service.WasteDisposalSiteVirescenceService;
import cn.lcvc.xnc.authority.config.security.UserUtil;
import cn.lcvc.xnc.authority.model.SysUser;
import cn.lcvc.xnc.authority.web.controller.backstage.BaseBackstageController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

@Api(tags = "复绿")
@RestController
@RequestMapping(value = "/api/backstage/waste/wastedisposalsitevirescence")
public class WasteDisposalSiteVirescenceController extends BaseBackstageController<WasteDisposalSiteVirescence, WasteDisposalSiteVirescenceQuery, Integer> {
    @Autowired
    private WasteDisposalSiteVirescenceService baseService;
    @Autowired
    private WasteDisposalSiteVirescencePictureService wasteDisposalSiteVirescencePictureService;
    @Autowired
    WasteDisposalSiteVirescencePictureMapper wasteDisposalSiteVirescencePictureMapper;

    @ApiOperation(value = "查询复绿记录")
    @GetMapping("/all")
    @Override
    protected ResponseData query(WasteDisposalSiteVirescenceQuery query) {
        return super.query(query);
    }

    @ApiOperation(value = "分页查询复绿记录")
    @Override
    protected ResponseData query(Integer page, Integer pageSize, WasteDisposalSiteVirescenceQuery query) {
        return super.query(page, pageSize, query);
    }

    @ApiOperation(value = "id查询复绿记录")
    @Override
    protected ResponseData get(@PathVariable("id") Integer id) {
        return super.get(id);
    }

    @ApiOperation(value = "移除复绿记录")
    @Override
    protected ResponseData deletes(@NotEmpty(message = "请选择要移除的记录") Integer[] ids) {
        return super.deletes(ids);
    }

    @ApiOperation(value = "添加复绿记录")
    @Override
    protected ResponseData add(@Valid @RequestBody WasteDisposalSiteVirescence wasteDisposalSiteVirescence) {
        return super.add(wasteDisposalSiteVirescence);
    }

    @ApiOperation(value = "修改复绿记录")
    @Override
    protected ResponseData edit(@Valid @RequestBody WasteDisposalSiteVirescence wasteDisposalSiteVirescence) {
        return super.edit(wasteDisposalSiteVirescence);
    }

    @ApiOperation("复绿图片")
    @PostMapping("/{id}/uploadimg")
    public ResponseData uploadImage(@PathVariable @NotNull(message = "请传入复绿id") Integer id, @NotNull(message = "请选择上传文件") MultipartFile[] file, String remark) {
        baseService.uploadHeadImgFile(id, file, remark);
        return ResponseData.success(null);
    }

    @ApiOperation("复绿图片url")
    @PostMapping("/uploadimgurl")
    public ResponseData uploadImageurl(Integer id) {
        return ResponseData.success(wasteDisposalSiteVirescencePictureMapper.findAll(id));
    }

    @ApiOperation("复绿图片url")
    @PostMapping("/uploadimgurlall")
    public ResponseData uploadImageurlall() {
        return ResponseData.success(wasteDisposalSiteVirescencePictureService.findAll(null));
    }
}
